/**
 */
package OBSL.impl;

import OBSL.OBSLPackage;
import OBSL.QualityCharacterizationLink;
import OBSL.QualityIndividual;

import RefOntoUML.Property;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Quality Individual</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.QualityIndividualImpl#getQuality <em>Quality</em>}</li>
 *   <li>{@link OBSL.impl.QualityIndividualImpl#getCharacterizes <em>Characterizes</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class QualityIndividualImpl extends IndividualImpl implements QualityIndividual {
	/**
	 * The cached value of the '{@link #getQuality() <em>Quality</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQuality()
	 * @generated
	 * @ordered
	 */
	protected Property quality;

	/**
	 * The cached value of the '{@link #getCharacterizes() <em>Characterizes</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCharacterizes()
	 * @generated
	 * @ordered
	 */
	protected QualityCharacterizationLink characterizes;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityIndividualImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.QUALITY_INDIVIDUAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Property getQuality() {
		if (quality != null && quality.eIsProxy()) {
			InternalEObject oldQuality = (InternalEObject)quality;
			quality = (Property)eResolveProxy(oldQuality);
			if (quality != oldQuality) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.QUALITY_INDIVIDUAL__QUALITY, oldQuality, quality));
			}
		}
		return quality;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Property basicGetQuality() {
		return quality;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setQuality(Property newQuality) {
		Property oldQuality = quality;
		quality = newQuality;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.QUALITY_INDIVIDUAL__QUALITY, oldQuality, quality));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public QualityCharacterizationLink getCharacterizes() {
		return characterizes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCharacterizes(QualityCharacterizationLink newCharacterizes, NotificationChain msgs) {
		QualityCharacterizationLink oldCharacterizes = characterizes;
		characterizes = newCharacterizes;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES, oldCharacterizes, newCharacterizes);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCharacterizes(QualityCharacterizationLink newCharacterizes) {
		if (newCharacterizes != characterizes) {
			NotificationChain msgs = null;
			if (characterizes != null)
				msgs = ((InternalEObject)characterizes).eInverseRemove(this, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY, QualityCharacterizationLink.class, msgs);
			if (newCharacterizes != null)
				msgs = ((InternalEObject)newCharacterizes).eInverseAdd(this, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY, QualityCharacterizationLink.class, msgs);
			msgs = basicSetCharacterizes(newCharacterizes, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES, newCharacterizes, newCharacterizes));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				if (characterizes != null)
					msgs = ((InternalEObject)characterizes).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES, null, msgs);
				return basicSetCharacterizes((QualityCharacterizationLink)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				return basicSetCharacterizes(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__QUALITY:
				if (resolve) return getQuality();
				return basicGetQuality();
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				return getCharacterizes();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__QUALITY:
				setQuality((Property)newValue);
				return;
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				setCharacterizes((QualityCharacterizationLink)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__QUALITY:
				setQuality((Property)null);
				return;
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				setCharacterizes((QualityCharacterizationLink)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.QUALITY_INDIVIDUAL__QUALITY:
				return quality != null;
			case OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES:
				return characterizes != null;
		}
		return super.eIsSet(featureID);
	}

} //QualityIndividualImpl
